import { Processor, IProcessor } from '@midwayjs/bull';
import { FORMAT, Inject } from '@midwayjs/decorator';
import { RedisService } from '@midwayjs/redis';

import { InjectEntityModel } from '@midwayjs/typeorm';
import { UserEntity } from 'src/entity/userinfo/user';
import { UserHistoryEntity } from 'src/entity/userinfo/userhistory';
import { Repository } from 'typeorm';

@Processor('UpdatahStatistics', {
  repeat: {
    // cron: FORMAT.CRONTAB.EVERY_PER_30_SECOND
   cron: FORMAT.CRONTAB.EVERY_DAY  // 每天零点 开始导入 用户浏览记录进入数据库
  }
})
export class UpdatahStatistics implements IProcessor {
  @Inject()
  logger;
  @InjectEntityModel(UserEntity)
  UserModel: Repository<UserEntity>; 
  @InjectEntityModel(UserHistoryEntity)
  UserHistoryModel: Repository<UserHistoryEntity>; 
  @Inject()
  redisService: RedisService;

  async execute() {
    // 查询前天记录 跟昨天记录

  }
}